import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:easy_video/controller/video/history_controller.dart';
import 'package:easy_video/widgets/auto_image_widget.dart';

class HistoryView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      builder: (controller) {
        return Scaffold(
          appBar: AppBar(
            title: Text(
              "观看历史",
            ),
          ),
          // body: SingleChildScrollView(
          //   child: Column(
          //     children: List.generate(
          //       10,
          //       (index) {
          //         return _item();
          //       },
          //     ),
          //   ),
          // ),
          body: Center(
            child: Text(
              "即将上线",
            ),
          ),
        );
      },
      init: HistoryController(),
    );
  }
}

class _item extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 130,
      margin: EdgeInsets.only(
        top: 20,
        left: 20,
        right: 20,
      ),
      decoration: BoxDecoration(
        color: Colors.white,
        boxShadow: [
          BoxShadow(
            color: Colors.grey.shade200,
            spreadRadius: 10,
            blurRadius: 10,
          ),
        ],
      ),
      child: Row(
        children: [
          Flexible(
            child: Container(
              decoration: BoxDecoration(
                  image: DecorationImage(
                    fit: BoxFit.cover,
                    image: AutoImage.buildImageProvider(
                      "",
                    ),
                  ),
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(15),
                    bottomLeft: Radius.circular(15),
                  )),
            ),
            flex: 1,
          ),
          Flexible(
            flex: 2,
            child: Container(
              padding: EdgeInsets.only(
                left: 15,
                right: 10,
              ),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    "The SpongeBob Movie",
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      color: Colors.grey,
                    ),
                  ),
                  Text(
                    "Sponge on the Run",
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      fontSize: 24,
                    ),
                  ),
                  Container(
                    child: LinearProgressIndicator(
                      value: 0.3,
                      color: Colors.red,
                      minHeight: 6,
                      borderRadius: BorderRadius.circular(10),
                    ),
                    padding: EdgeInsets.only(
                      top: 5,
                      bottom: 5,
                    ),
                  ),
                  Text(
                    "00:02:10",
                    style: TextStyle(
                      color: Colors.red,
                    ),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
